package com.base.caselib.presenter;

import android.app.Activity;
import android.text.TextUtils;
import android.util.Log;

import com.base.caselib.bean.CaseListBean;
import com.base.caselib.bean.Process;
import com.base.caselib.view.CaseProcessView;
import com.base.commonlib.base.presenter.BasePresenter;
import com.base.commonlib.http.RealNetWorkUtil;
import com.base.commonlib.http.utils.CallBackImpl;

import java.util.HashMap;
import java.util.List;

import io.reactivex.disposables.Disposable;

/**
 * Created by Administrator on 2019/10/30.
 */

public class CaseProcessPresenter extends BasePresenter<CaseProcessView> {
    public CaseProcessPresenter(CaseProcessView view, Activity activity) {
        super(view, activity);
    }


    public void getCaseProcess(String id) {
        //初始化控件
        mView.showPb_mes("正在获取数据");
        HashMap<String, Object> params = new HashMap<>();
        params.put("caseId",id);
        Disposable disposable = RealNetWorkUtil.get()
                .method("/api-process/lApp/getListByCaseId")
                .params(params)
                .build().enqueueForArray(Process.class, new CallBackImpl<List<Process>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        if (!TextUtils.isEmpty(msg)) {
                            mView.showMes(msg);
                        }
                    }

                    @Override
                    public void onNext(List<Process> process) {
                        mView.hidePb_mes();
                        if (process == null){
                            mView.showMes("再无流程");
                        }
                        mView.returnCaseProcessBean(process);
                    }
                });
        mCompositeDisposable.add(disposable);
    }


}
